package com.fyyg.common.aliyun.oss;

/**
 * @author hang.ouyang
 * @date 2016-04-07 10:51
 */
public class OSSImageUrlUtil {

    private static String domain = OSSObject.OSS_IMAGE_DOMAIN;

    //去掉域名后面重复的'/'
    static{
        while(domain.lastIndexOf("/") == domain.length() - 1){
            domain = domain.substring(0,domain.length() - 1);
        }
        domain +=  "/";
    }
    /**
     * 图片相对路径转为全路径
     * @param relativePath
     */
    public static String converToOverallPath(String relativePath){
        //除去相对路径前面的所有'/'
        while(relativePath.indexOf("/") == 0){
            relativePath = relativePath.substring(1);
        }
        return domain + relativePath;
    }
    /**
     * 获得图片服务器域名
     * @return
     */
    public static String getImgDomain(){
        return domain;
    }
}
